home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!netnews
- From: judgemi@ix.netcom.com(Michael Judge )
- Newsgroups: comp.lang.c++
- Subject: Re: new and 2-D Arrays?
- Date: 7 Feb 1996 19:08:48 GMT
- Organization: Netcom
- Message-ID: <4fatc0$8lg@cloner4.netcom.com>
- References: <4famh5$chp@canyon.sr.hp.com>
- NNTP-Posting-Host: bos-ma8-25.ix.netcom.com
- X-NETCOM-Date: Wed Feb 07 11:08:48 AM PST 1996
-
- In <4famh5$chp@canyon.sr.hp.com> rolando@sr.hp.com (Rolando Ampuero)
- writes:
- >
- >Hello, This question was problably asked already, but as a newbie in
- the
- >world of C++, this is one place I found that relates to this subject.
- >According to several manuals that I have read I can declare a two
- dimensional
- >array in this manner
- >
- >int *myptr = new int [8][8];
- >
- >but when I tried to compile I get errors, is this not the correct way
- to do
- >it? Are the books wrong? (One of the books is Deitel pg 415).
- >
- >If there is a FAQ site where I can go to, please let me know.
- >
- >--
-
- I cant exactly tell you why the compile error, but I can tell you that
- even if it compiled, you wouldn't be able to index it properly. how can
- the compiler know how to offset myptr[3][4]. It would have to remember
- to multiply 3*8 and add 4 to get to the proper address. Unless you
- declare this myptr[8][4], at compile time It cant prepare the proper
- constants( in this case 8) to be multiplied to the first index.
-
- MJ
-
-